<script setup name="Index">
import { tableOptions } from '@/plugins/vxetable.js'
import { ElInput } from 'element-plus'
import BaseDialog from "@/components/BaseDialog/BaseDialog.vue";
import BaseForm from "@/components/BaseForm/BaseForm.vue";

const table = reactive({
  ...tableOptions(),
  columns: [
    {
      field: 'id',
      title: 'ID',
      width: 80,
      visible: false,
    },
    {
      field: 'name',
      title: 'Name',
      width: 200,
      editRender: {
        type: 'input',
        attrs: {
          placeholder: 'Please input name',
        },
      },
    },
    {
      field: 'age',
      title: 'Age',
      width: 100,
      editRender: {
        type: 'input',
        attrs: {
          type: 'number',
          placeholder: 'Please input age',
        },
      },
    },
    {
      field: 'address',
      title: 'Address',
      width: 300,
      editRender: {
        type: 'textarea',
        attrs: {
          placeholder: 'Please input address',
        },
      },
    },
  ],
  data: [
    { id: 1, name: 'John', age: 20, address: 'New York' },
    { id: 2, name: 'Smith', age: 25, address: 'London' },
    { id: 3, name: 'Lee', age: 30, address: 'Paris' },
  ],
  pagerConfig: {
    pageSize: 10,
    pageSizes: [10, 20, 30, 40, 50],
  },
})
const form = ref({})

const FormColumns = ref([
  {
    label: 'ID',
    field: 'id',
  },
  {
    label: 'Name',
    field: 'name',
    type:'select',
    options: [
      {
        label: 'John',
        value: 'John',
      },
      {
        label: 'Smith',
        value: 'Smith',
      }
    ]
  }
])
const testVisible = ref(false)

function test() {
  testVisible.value = true
}
</script>

<template>
  <div class="app-container home">
    <vxe-grid
      v-bind="table"
    />
    <el-button @click="test">
      测试
    </el-button>
    <base-dialog title="测试" v-model:visible="testVisible">
      12
    </base-dialog>
    <el-card>
      <base-form :columns="FormColumns"/>
    </el-card>
  </div>
</template>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>
